home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 6
/
The Arsenal Files 6 (Arsenal Computer).ISO
/
prg_casm
/
jlvesa11.zip
/
JLVESA09.ASM
< prev
next >
Wrap
Assembly Source File
|
1995-11-14
|
7KB
|
383 lines
; This routine is part of VESA SVGA -library
;
; Copyright 1994 Johannes Lehtinen
; All rights reserved
model large,c
p386
include "jlvesads.asm"
extrn vesa_repos_w:far
segment jlvesa09_TEXT USE16 'CODE'
assume cs:jlvesa09_TEXT
lines_left dw ? ; Number of lines left
repo_lines dw ? ; Lines before reposition check
l_width dw ? ; Movement per line (signed)
l_width_u dw ? ; Movement per line (unsigned)
counter dw ? ; Counter
reset_c dw ? ; Counter reset value
add_c dw ? ; Counter add value
addition dw ? ; Addition value for linelength if counter full
direction db ? ; Direction of move (-1/1 = left/right)
; void JVLine_Draw(JVSWord x1, JVSWord y1, JVSWord x2, JVSWord y2,
; JVUByte color)
;
; Draws line from (x1,y1) to (x2,y2) with color color.
proc JVLine_Draw far
public JVLine_Draw
push bp
mov bp,sp
push di
push ds
push es
mov ax,JLVesa_Data ; DS = Data segment
mov ds,ax
mov ax,[ds:WWSeg]
mov es,ax ; ES = Write window segment
; Check if line is horizontal
mov ax,[ss:bp+8]
cmp [ss:bp+12],ax
je horizontal_line
; Line is not horizontal
; Check that y1 < y2
ja short y_right_order
xchg ax,[ss:bp+12]
mov [ss:bp+8],ax
mov ax,[ss:bp+6]
xchg ax,[ss:bp+10]
mov [ss:bp+6],ax
; Calculate start address
y_right_order:
xor eax,eax
xor ebx,ebx
mov ax,[ss:bp+8]
mov bx,[ds:LWidth]
mul ebx
mov dx,[ss:bp+6]
add eax,edx
add eax,[ds:AStart]
mov ecx,eax ; ECX = start address
; Calculate x-movement
mov ax,[ss:bp+10]
sub ax,[ss:bp+6]
cmp ax,0
jl short leftwards
mov [cs:direction],1
inc ax
jmp short calc_lines
leftwards:
mov [cs:direction],-1
dec ax
; Calculate number of lines
calc_lines:
mov bx,[ss:bp+12]
sub bx,[ss:bp+8]
inc bx
mov [cs:lines_left],bx
; Calculate x-movement per line
mov [cs:reset_c],bx
cwd
idiv bx
mov [cs:add_c],dx
mov [cs:l_width],ax
mov [cs:l_width_u],ax
mov [cs:counter],dx
; Calculate addition value
mov [cs:addition],1
cmp ax,0
je short check_dir
mov [cs:addition],0
check_dir:
cmp [cs:direction],0
jg short repos_win_first
; Recalculate start address if line goes leftwards
recalc_start:
xor ebx,ebx
sub bx,ax
mov [cs:l_width_u],bx
sub ecx,ebx
inc ecx
xor bx,bx
sub bx,[cs:add_c]
mov [cs:add_c],bx
mov [cs:counter],bx
; Reposition window if necessary
repos_win_first:
mov edx,ecx
cmp [ds:WAStart],ecx
jbe short dont_repos
call far vesa_repos_w
dont_repos:
mov edi,edx
sub edi,[ds:WAStart]
; Check if need to reposition window
check_repos:
mov eax,edx
sub eax,[ds:WAStart]
cmp [ds:WSize],eax
ja short dont_repos2
; Reposition window
call far vesa_repos_w
mov edi,edx
sub edi,[ds:WAStart]
; Calculate lines before next reposition check
dont_repos2:
mov eax,[ds:WAStart]
add eax,[ds:WSize]
sub eax,edx
push edx
xor ebx,ebx
xor edx,edx
mov bx,[ds:LWidth]
div ebx
pop edx
cmp ax,0
je short dont_decrease
dec ax
dont_decrease:
mov [cs:repo_lines],ax
; Calculate the length of the line
line_loop:
mov cx,[cs:l_width_u]
mov ax,[cs:reset_c]
cmp [cs:counter],ax
jb short dont_add
inc cx
sub [cs:counter],ax
jmp short dont_add2
; Check if no side movement
dont_add:
add cx,[cs:addition]
; Draw one line
; Check if reposition check necessary
dont_add2:
cmp [cs:repo_lines],0
je draw_repos_line
; Line is on one page
on_one_page2:
mov al,[ss:bp+14]
rep stosb
; Calculate offset for next line
calc_next_line:
xor eax,eax
mov ax,[ds:LWidth]
add ax,[cs:l_width]
add edx,eax
cmp [cs:direction],0
jg short right_part
mov ax,[cs:add_c]
add [cs:counter],ax
mov ax,[cs:reset_c]
cmp [cs:counter],ax
jb short dont_add3
dec edx
dont_add3:
mov edi,edx
sub edi,[ds:WAStart]
dec [cs:lines_left]
jz return
cmp [cs:repo_lines],1
jbe check_repos
dec [cs:repo_lines]
jmp line_loop
right_part:
mov bx,[cs:add_c]
cmp [cs:counter],bx
jae short dont_add4
inc edx
dont_add4:
add [cs:counter],bx
mov edi,edx
sub edi,[ds:WAStart]
dec [cs:lines_left]
jz return
cmp [cs:repo_lines],1
jbe check_repos
dec [cs:repo_lines]
jmp line_loop
; Check if line fits on current page (Calculate bytes left in this
; page)
draw_repos_line:
mov ebx,[ds:WAStart]
add ebx,[ds:WSize]
sub ebx,edx
cmp bx,cx
jb short on_two_pages
jmp on_one_page2
; Line is on two pages
on_two_pages:
xchg bx,cx ; CX = bytes on this page
sub bx,cx
push bx
xor ebx,ebx
mov bx,cx
mov al,[ss:bp+14]
rep stosb
; Switch page
add edx,ebx
call far vesa_repos_w
mov edi,edx
sub edi,[ds:WAStart]
sub edx,ebx
pop bx
mov cx,bx
rep stosb
jmp calc_next_line
; Draw horizontal line
; Calculate length of line in BX
horizontal_line:
mov bx,[ss:bp+10]
sub bx,[ss:bp+6]
cmp bx,0
jge short dont_switch_sign
; Switch sign of BX
xor ax,ax
sub ax,bx
mov bx,ax
; Calculate start address
dont_switch_sign:
inc bx
mov [cs:l_width],bx
xor eax,eax
xor edx,edx
xor ecx,ecx
mov ax,[ss:bp+8]
mov dx,[ds:LWidth]
mul edx
mov cx,[ss:bp+6]
cmp [ss:bp+10],cx
jg short dont_switch_x
mov cx,[ss:bp+10]
dont_switch_x:
add eax,ecx
add eax,[ds:AStart]
mov edx,eax
; Check if need to reposition window
cmp [ds:WAStart],edx
jbe short not_over
call far vesa_repos_w
jmp short in_page
not_over:
sub eax,[ds:WAStart]
cmp [ds:WSize],eax
ja short in_page
call far vesa_repos_w
; Draw pixels in this page
in_page:
mov al,[ss:bp+14] ; Drawing color
mov edi,edx
sub edi,[ds:WAStart]
mov cx,[cs:l_width]
mov ebx,[ds:WSize]
sub ebx,edi
cmp cx,bx
jbe short on_one_page
; On two pages
add edx,ebx
sub [cs:l_width],bx
mov cx,bx
rep stosb
call far vesa_repos_w
mov cx,[cs:l_width]
mov edi,edx
sub edi,[ds:WAStart]
; On one page
on_one_page:
rep stosb
; Return
return:
pop es
pop ds
pop di
pop bp
retf
endp JVLine_Draw
ends
end